<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
     <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-form-item label="支付渠道" style="margin-right: 10px">
            <a-select
              v-model="queryParam.channelType"
              style="width: 120px"
              :options="channelTypeoPtions"
              allowClear
              placeholder="请选择"
              @change="searchQuery"
            />
          </a-form-item>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <!-- <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>

      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel">
            <a-icon type="delete" />
            删除
          </a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px">
          批量操作
          <a-icon type="down" />
        </a-button>
      </a-dropdown>

    </div> -->
    <!-- table区域-begin -->
    <div>
      <!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a
        >项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div> -->

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        @change="handleTableChange"
      >
        <template slot="status" slot-scope="text, record">
          <a-switch default-checked :checked="record.status" @change="statusChange(record)" />
        </template>

        <!-- <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span> -->
      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <xhdjPayMethod-modal ref="modalForm" @ok="modalFormOk"></xhdjPayMethod-modal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import XhdjPayMethodModal from './modules/XhdjPayMethodModal'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { httpAction } from '@/api/XhdjPayMethodList.js'

export default {
  name: 'XhdjPayMethodList',
  mixins: [JeecgListMixin],
  components: {
    XhdjPayMethodModal
  },
  data () {
    return {
      payTypes: {
        1: '余额',
        2: '微信',
        3: '支付宝'
      },
      channelTypes: {
        0: '用户端公众号',
        1: '用户端App',
        2: '技师端公众号',
        3: '技师端APP'
      },

      description: '支付配置管理页面',
      options: [
        // 支付类型(1会员余额     2支付宝    3微信APP微信     4公众号微信（爱星河到家）
        { label: '会员余额', value: '1', color: 'orange' },
        { label: '支付宝', value: '2', color: 'green' },
        { label: '微信(app)', value: '3', color: '#999' },
        { label: '微信(公众号)', value: '4', color: 'orange' }
      ],
      channelTypeoPtions: [
        // 渠道类型（0用户端公众号 1用户端APP 2技师端公众号 3技师端APP）
        { label: '用户端公众号', value: '0', color: 'orange' },
        { label: '用户端APP', value: '1', color: 'green' },
        { label: '技师端公众号', value: '2', color: '#999' },
        { label: '技师端APP', value: '3', color: 'orange' }
      ],


      // 表头
      columns: [
        {
          title: '支付参数',
          align: 'center',
          dataIndex: 'payType'
        },
        {
          title: '支付参数枚举',
          align: 'center',
          dataIndex: 'payEg'
        },
        {
          title: '状态：',
          align: 'center',
          dataIndex: 'status',
          scopedSlots: { customRender: 'status' }
        },
        {
          title: '渠道类型',
          align: 'center',
          dataIndex: 'channelType',
          customRender: (text, record) => {
            return this.channelTypes[record.channelType]
          }
        },
        {
          title: '排序号',
          align: 'center',
          dataIndex: 'sortSerial'
        },
        {
          title: '资金类型',
          align: 'center',
          dataIndex: 'moneyType',
          customRender: (text, record) => {
            return this.payTypes[record.moneyType]
          }
        },

        {
          title: '支付名',
          align: 'center',
          dataIndex: 'payName'
        },
        {
          title: '说明',
          align: 'center',
          dataIndex: 'content'
        }
        // {
        //   title: '操作',
        //   dataIndex: 'action',
        //   align: 'center',
        //   scopedSlots: { customRender: 'action' }
        // }
      ],
      url: {
        list: '/pay/xhdjPayMethod/list',
        delete: '/pay/xhdjPayMethod/delete',
        deleteBatch: '/pay/xhdjPayMethod/deleteBatch',
        exportXlsUrl: '/pay/xhdjPayMethod/exportXls',
        importExcelUrl: '/pay/xhdjPayMethod/importExcel',
        examine: '/pay/xhdjPayMethod/edit'
      }
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    // 改变状态
    statusChange (record) {
      let a = {
        id: record.id,
        status: record.status ? 0 : 1
      }
      httpAction(this.url.examine, a, 'post').then(res => {
        if (res.success) {
          console.log('修改成功！')
          this.loadData()
        } else {
          that.$message.warning(res.message)
        }
      })
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
